<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>品牌聚惠</title>
    <link rel="stylesheet" href="../style/brabd-922/style.css">
</head>

<body>
    <div class="header"></div>
    <div class="ctn">
        <div class="top">
            <div></div>
        </div>
        <div class="wrap">
        </div>
        <div class="footer">
            <ul>
            </ul>
            <div class="back-up">返回顶部</div>
        </div>
    </div>
    <div class="footer"></div>
    <!-- template start -->
    <script type="text/html" id="tpl-ctx">
        {{each $data}}
        <div class="container">
            <span>{{$value.name}}</span>
            <a href="{{$value.bigHref}}" class="big-product" target='_blank'>
                <span class='big-old big-old-{{$index+1}}'>原价:{{$value.bigOld}}元</span>
                <span class='big-new big-new-{{$index+1}}'>{{$value.bignew}}</span>
                <img src="{{$value.bigProduct}}" alt="">
            </a>
            <div class="min-product">
                {{each $value.productId}}
                <div class="card">
                </div>
                {{/each}}
            </div>
            <div class="more">
                <a target='_blank' href="{{$value.more}}">更多选择，请点击&gt;&gt;</a>
            </div>
        </div>
        {{/each}}
    </script>
    <script type="text/html" id="tpl-card">
        <a class="card-img" href="{{href}}">
            <img src="{{pic}}" alt="">
        </a>
        <div>
            <p>{{name}}</p>
            <div class="clearfix">
                <span class="cb-1 fl">活动价￥</span>
                <span class="cb-2 fl">{{discountPrice}}</span>
                <a href="{{href}}" target='_blank' class="cb-3 fr">
                    <p>原价:{{price_on_tag}}元</p>
                    <div>立即抢购&nbsp;&gt;</div>
                </a>
            </div>
        </div>
    </script>
    <script type="text/html" id="tpl-logo">
        {{each $data}}
        <li>
            <a href="{{$value.href}}" target='_blank'>
                <img src="../images/brabd-922/logo0{{$value.idx}}.png" alt="{{$value.name}}">
            </a>
        </li>
        {{/each}}
    </script>
</body>
<script src="../../js/jquery-1.8.3.min.js"></script>
<script src="../../js/art-template.js"></script>
<script src="../../js/model.js"></script>
<script>
    (function ($, template) {
        var dataId = [{
                name: '创 维',
                bigProduct: '../images/brabd-922/big-product01.png',
                bigHref: 'http://www.cjwsc.com/item/93151.html',
                bigOld:3999,
                bignew:2799,
                productId: [93151, 140514, 92879, 93114, 93120, 92942, 146595, 117189, 96966],
                more: 'http://www.cjwsc.com/lists/2895-040101-0.html'
            },
            {
                name: '康 佳',
                bigProduct: '../images/brabd-922/big-product02.png',
                bigHref: 'http://www.cjwsc.com/item/113165.html',
                bigOld:1699,
                bignew:1299,
                productId: [113165, 118011, 133951, 118013, 113265, 123672, 116447, 113288, 113378],
                more: 'http://www.cjwsc.com/lists/245-040101-0.html'
            },
            {
                name: '长 虹',
                bigProduct: '../images/brabd-922/big-product03.png',
                bigHref: 'http://www.cjwsc.com/item/135336.html',
                bigOld:1299,
                bignew:1099,
                productId: [135336, 135355, 135352, 135476, 135340, 135346, 135473, 135338, 135363],
                more: 'http://www.cjwsc.com/lists/1670-040101-0.html'
            },
            {
                name: '夏 普',
                bigProduct: '../images/brabd-922/big-product04.png',
                bigHref: 'http://www.cjwsc.com/item/143858.html',
                bigOld:2190,
                bignew:2090,
                productId: [143858, 143870, 143984, 143985, 143982, 143983],
                more: 'http://www.cjwsc.com/lists/2804-040101-0.html'
            }
        ]

        function jsonp(id, idx, index) {
            $.ajax({
                url: 'http://www.cjwsc.com/qcwdProduct/getProductByIds',
                data: {
                    ids: id,
                    business_type: 10,
                    client_type: 1
                },
                dataType: "jsonp",
                jsonp: 'jsonpcallback',
                success: function (res) {
                    res.msg[0].href = 'http://www.cjwsc.com/item/' + id + '.html';
                    res.msg[0].pic = res.msg[0].pic.replace('240_240', '800_800')
                    var tpls = template('tpl-card', res.msg[0])
                    $('.container').eq(idx).find('.card').eq(index).html(tpls)
                    if (index == 0) {
                        var tplStr = '<span class="red-title"><p>' + '热销爆款' +
                            '</p><span></span></span>';
                        $('.container').eq(idx).find('.card').eq(index).append(tplStr)
                    } else if (index == 1 || index == 2) {
                        var tplStr = '<span class="red-title"><p>' + '站长推荐' +
                            '</p><span></span></span>';
                        $('.container').eq(idx).find('.card').eq(index).append(tplStr)
                    }

                }
            })
        }

        function getData(dataId) {
            var tpl = template('tpl-ctx', dataId)
            $('.wrap').html(tpl);
            dataId.forEach(function (v, i) {
                v.productId.forEach(function (_v, _i) {
                    jsonp(_v, i, _i)
                })
            });
        }

        function getLogo() {
            var logoInfo = [{
                    name: '飞利浦',
                    href: 'http://www.cjwsc.com/lists2/1885-040101-0-0-1.html',
                    idx: 1
                },
                {
                    name: '现代',
                    href: 'http://www.cjwsc.com/lists/2732-040101-0.html',
                    idx: 2,
                },
                {
                    name: '海信',
                    href: 'http://www.cjwsc.com/lists/3007-040101-0.html',
                    idx: 3
                },
                {
                    name: '海尔',
                    href: 'http://www.cjwsc.com/lists2/1039-040101-0-0-1.html',
                    idx: 4
                },
                {
                    name: '索尼',
                    href: 'http://www.cjwsc.com/lists/2573-040101-0.html',
                    idx: 5
                },
                {
                    name: '东芝',
                    href: 'http://www.cjwsc.com/lists/2884-040101-0.html',
                    idx: 6
                },
                {
                    name: '乐视',
                    href: 'http://www.cjwsc.com/lists/2607-040101-0.html',
                    idx: 7
                },
                {
                    name: 'TCL',
                    href: 'http://www.cjwsc.com/lists/23-040101-0.html',
                    idx: 8
                }
            ]

            $('.footer ul').html(template('tpl-logo', logoInfo))
        }

        function backUp(ele) {
            ele.on('click', function () {
                $('html,body').animate({
                    scrollTop: 0
                }, 500)
            })
        }

        getData(dataId)
        getLogo()
        backUp($('.back-up'))
        $('.header').topBox()
        $('.footer').footBox()
    }($, template))
</script>

</html>